package org.chenjian.portal80.controller;
import org.chenjian.portal80.dao.UserDao;
import org.chenjian.portal80.model.Theuser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;


@Controller
public class MainController {

    @Autowired
    UserDao userDao;
    @Autowired
    Theuser theuser;
    Logger logger=  LoggerFactory.getLogger(MainController.class);
    @RequestMapping("/")
    public String abc(){
         logger.info("hello");

        return "login";
    }

    @RequestMapping(value="login")
    @ResponseBody
    public String login(String uname, String upassword, HttpSession session){
        theuser = userDao.selectUserByInfo(uname,upassword);
        if(ObjectUtils.isEmpty(theuser)){
            return "not";
        }
        else {
            session.setAttribute("theuser",theuser);
            return "ok";
        }
    }
    @RequestMapping("page/table")
    public String tables(){
        logger.info("...........");

         return "tables";
    }
}
